function food(el)
{
this.el=el
this.length=20
this.foodObj=null
this.foodX=0
this.foodY=0
}
food.prototype.create=function(){
    let divObj=document.createElement("div")
    divObj.style.width=this.length+"px"
    divObj.style.height=this.length+"px"
    divObj.style.background="green"
    divObj.style.position="absolute"
    this.foodObj = divObj
    this.el.appendChild(divObj)
    this.move()//专门用来放食物的坐标数据

}
food.prototype.move=function(){
    let MaxX=this.el.clientWidth/this.length-1
    let MaxY=this.el.clientHeight/this.length-1
    this.foodX=Math.floor(Math.random()*(MaxX+1))*this.length
    this.foodY=Math.floor(Math.random()*(MaxY+1))*this.length
    this.foodObj.style.left = this.foodX + 'px'
    this.foodObj.style.top = this.foodY + 'px'
}